import http from '@/common/js/httpRequest'
//获取货品列表
export function getProductList (params) {
  return http({
    method: 'get',
    url: '/api/base/product/list',
    params
  })
}
//获取货品项目值的对应列表
export function getProductItemMaps (params) {
  return http({
    method: 'get',
    url: '/api/base/product/item/map/list',
    params
  })
}
//保存或修改货品项目值的对应列表
export function saveOrUpdateProductItemMap (data) {
  return http({
    method: 'post',
    url: '/api/base/product/item/map/save',
    data,
    openDefultdata: true
  })
}
//获取品规
export function getProductNameSpecs (params) {
  return http({
    method: 'get',
    url: '/api/base/product/ns/list',
    params
  })
}
//获取货品对应车间流水号
export function getWaterWorkshopByProductId (params) {
  return http({
    method: 'get',
    url: '/api/base/product/water/workshops',
    params
  })
}
//获取货品列表ByStandardId
export function getProductListByStandardId (params) {
  return http({
    method: 'get',
    url: '/api/base/product/listByStandardId',
    params
  })
}
//获取货品列表ByProjectId
export function getProductListByProjectId (params) {
  return http({
    method: 'get',
    url: '/api/base/product/listByProjectId',
    params
  })
}
//获取货品分类
export function getProductCategorys () {
  return http({
    method: 'get',
    url: '/api/base/product/categorys'
  })
}
//保存或者修改货品
export function saveOrUpdateProduct (data) {
	const url = data.isUpgrade ? '/api/base/product/upgrade' : !data.productId ? '/api/base/product/save' : '/api/base/product/update'
  return http({
    method: 'post',
    url: url,
    data
  })
}
//保存或者修改货品
export function updateSerialNum (data) {
  return http({
    method: 'post',
    url: '/api/base/product/update/serial',
    data
  })
}
//删除货品
export function deleteProduct (ids) {
  return http({
    method: 'post',
    url: '/api/base/product/delete',
    data: ids,
    openDefultdata: true
  })
}
//获取货品包装规格
export function getProductPackSpecsByProductId (params) {
  return http({
    method: 'get',
    url: '/api/base/product/packSpecs',
    params
  })
}
//保存包装规格
export function saveProductPackSpec (data) {
  return http({
    method: 'post',
    url: '/api/base/product/savePackSpec',
    data
  })
}
//删除包装规格
export function deleteProductPackSpec (id) {
  return http({
    method: 'post',
    url: `/api/base/product/deletePackSpec?productPackSpecId=${id}`
  })
}
//获取货品工序流程
export function getProductProcess (params) {
  return http({
    method: 'get',
    url: '/api/base/product/process',
    params
  })
}
//获取货品工序流程one
export function getProductProcessOne (params) {
  return http({
    method: 'get',
    url: '/api/base/product/process/one',
    params
  })
}
//保存或修改货品工序流程
export function saveOrUpdateProductProcess (data) {
  return http({
    method: 'post',
    url: '/api/base/product/process/save',
    data
  })
}
//删除货品工序流程
export function deleteProcess (data) {
  return http({
    method: 'post',
    url: '/api/base/product/process/delete',
    data
  })
}
//同步货品
export function syncProduct (data) {
  return http({
    method: 'post',
    url: '/api/base/product/sync',
    data
  })
}
//货品名称修改为通用
export function updateProductName (data) {
  return http({
    method: 'post',
    url: '/api/base/product/update/name',
    data
  })
}
//获取特殊货品byname
export function querySpecialProductByName (params) {
  return http({
    method: 'get',
    url: '/api/base/product/special/list',
    params
  })
}
// 获取货品的每个年份的报告流水号
export function getProductSerialsByProductIdOrPrefix(params) {
  return http({
    method: 'get',
    url: '/api/base/product/serials',
    params
  })
}

//获得货品贮存条件
export function getStorageConditionsByProductId (params) {
  return http({
    method: 'get',
    url: '/api/base/product/storageConditions',
    params
  })
}

//保存贮存条件
export function saveStorageConditions (data) {
  return http({
    method: 'post',
    url: '/api/base/product/saveStorageConditions',
    data
  })
}

//删除贮存条件
export function deleteStorageConditions (id) {
  return http({
    method: 'get',
    url: '/api/base/product/deleteStorageConditions/'+id
  })
}
